package com.mobilnaElka.activities.search;

import java.util.ArrayList;

import android.app.*;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

import com.mobilnaElka.activities.R;
import com.mobilnaElka.models.calendar.Consts;


public class SearchActivity extends ListActivity {


	@SuppressWarnings("unchecked")
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		
		Bundle extras = getIntent().getExtras();
		ArrayList<String> stuffNames = null;
		
		if(extras !=null)
		{
			stuffNames = (ArrayList<String>)extras.get("stuffNames");
		}

		this.setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, stuffNames));
		
	}
	
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Object o = this.getListAdapter().getItem(position);
		String keyword = o.toString();
		
		Toast.makeText(this, getString(R.string.you_selected)+ " " + keyword, Toast.LENGTH_LONG)
				.show();
		
		Intent intent = new Intent(SearchActivity.this, SearchTabActivity.class);
		intent.putExtra(Consts.NAZW_IM, keyword);
		finish();
		startActivityForResult(intent, Activity.RESULT_OK);
		
	}
	
	@Override
	public void onBackPressed() {
		Intent myIntent = new Intent(SearchActivity.this, SearchSettings.class);
		finish();
		startActivityForResult(myIntent, 0);


	}
	

}
